package com.ruoyi.web.controller.wb;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wb.domain.WbFireServiceUser;
import com.ruoyi.wb.dto.WbFireServiceUserDto;
import com.ruoyi.wb.service.IWbFireServiceUserService;
import com.ruoyi.wb.vo.WbFireServiceUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 消防用户Controller
 * 
 * @author ruoyi
 * @date 2025-01-06
 */
@RestController
@RequestMapping("/wb/fireServiceUser")
public class WbFireServiceUserController extends BaseController
{
    @Autowired
    private IWbFireServiceUserService wbFireServiceUserService;



    /**
     * 导出消防用户列表
     */
    @Log(title = "消防用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbFireServiceUser wbFireServiceUser)
    {
        List<WbFireServiceUser> list = wbFireServiceUserService.selectWbFireServiceUserList(wbFireServiceUser);
        ExcelUtil<WbFireServiceUser> util = new ExcelUtil<WbFireServiceUser>(WbFireServiceUser.class);
        util.exportExcel(response, list, "消防用户数据");
    }

    /**
     * 获取消防用户详细信息
     */
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        WbFireServiceUserVo wbFireServiceUserVo = wbFireServiceUserService.byUserId(userId);
        return success(wbFireServiceUserVo);
    }

    /**
     * 新增消防用户
     */
    @Log(title = "消防用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbFireServiceUserDto wbFireServiceUserDto)
    {
        return toAjax(wbFireServiceUserService.addByWbFireServiceUserDto(wbFireServiceUserDto));
    }

    /**
     * 修改消防用户
     */
    @Log(title = "消防用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbFireServiceUserDto wbFireServiceUserDto)
    {
        return toAjax(wbFireServiceUserService.editByWbFireServiceUserDto(wbFireServiceUserDto));
    }

    /**
     * 删除消防用户
     */
    @Log(title = "消防用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wbFireServiceUserService.deleteWbFireServiceUserByIds(ids));
    }


    /**
     * 查询消防用户列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WbFireServiceUserDto wbFireServiceUserDto)
    {
        startPage();
        List<WbFireServiceUserVo> list = wbFireServiceUserService.listByWbFireServiceUserDto(wbFireServiceUserDto);
        return getDataTable(list);
    }
}
